;; EX-39 - Artificial Space (JMcC)

;; From the file 'Help/UGens/Tour_of_UGens.rtfd' in SC3.

;; Building a sense of space into a sound by setting up phase
;; differences between the speakers.

(let ((x (BrownNoise.ar 0.2))) (list x x)) ; correlated

(BrownNoise.ar (list 0.2 0.2))		   ; not correlated

(let ((x (LPF.ar (BrownNoise.ar 0.2) 
		 (MouseX.kr 100 10000)))) (list x x)) ; correlated

(LPF.ar (BrownNoise.ar (list 0.2 0.2)) (MouseX.kr 100 10000)) ; not correlated

(let ((x (Klank.ar spec: (Klank.spec '(200 671 1163 1723) '(1 1 1 1) '(1 1 1 1))
		   in: (PinkNoise.ar 7e-3))))
  (list x x))				; correlated

(Klank.ar spec: (Klank.spec '(200 671 1163 1723) '(1 1 1 1) '(1 1 1 1))
		   in: (PinkNoise.ar (list 7e-3 7e-3))) ; not correlated

;; Two waves mixed together coming out both speakers

(let ((x (Mix (VarSaw.ar '(100 101) 0 0.1 0.2)))) (list x x))

;; Two waves coming out each speaker independantly

(VarSaw.ar '(100 101) 0 0.1 (* 0.2 1.414))

;; Inter-speaker delays as cues to direction.

(let ((x (LFTri.ar 1000 0 (Decay2.ar (Impulse.ar 4 0 0.2) 0.004 0.2))))
  (list (DelayC.ar x 0.01 0.01) (DelayC.ar x 0.02 (MouseX.kr 0 0.02))))

;; Mixing two delays together.  There is a phasing sound but the sound
;; is still flat.

(let* ((x (BrownNoise.ar 0.2))
       (y (Mix (list (DelayC.ar x 0.01 0.01) (DelayC.ar x 0.02 (MouseX.kr 0 0.02))))))
  (list y y))

;; Phasing causes you to perceive directionality

(let ((x (BrownNoise.ar 0.2)))
  (list (DelayC.ar x 0.01 0.01) (DelayC.ar x 0.02 (MouseX.kr 0 0.02))))
